package cn.tedu.logistics.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import cn.tedu.logistics.bean.Shop;
import cn.tedu.logistics.dao.ShopDao;
import cn.tedu.logistics.utils.BeanValidate;

@Service
public class ShopServiceImpl implements ShopService{
	@Autowired
	private ShopDao shopDao;
	
	//查询所有门店信息
	public List<Shop> findAllShop() {
		List<Shop> list=shopDao.selectList(null);
		return list;
	}
	
	//新增门店信息
	public void addShop(Shop shop) {
		shopDao.insert(shop);
	}
	
	//删除门店信息
	public void delShop(String shopId) {
		shopDao.deleteById(shopId);	
	}
	
	//修改门店信息
	public Shop selectById(String shopId) {
		return shopDao.selectById(shopId);
	}
	
	//修改门店信息
	public void updateShop(Shop shop) {
		if(BeanValidate.checkNull(shop)) {
			System.out.println("存在空值");
			return;
		}
		shopDao.updateById(shop);
	}
	//校验门店信息
	@Override
	public int checkShopId(String shopId) {
		QueryWrapper<Shop> queryWrapper = new QueryWrapper<Shop>();
		queryWrapper.eq("shop_Id", shopId);
		List<Shop> list = shopDao.selectList(queryWrapper);
		return (list == null || list.size() == 0) ? 0 : 1;
	}

}
